class WebConfigsController < ApplicationController
  # GET /web_configs
  # GET /web_configs.xml
    uses_tiny_mce :options => {
    :width => '620',
    :height => '400',
    :theme =>  "advanced",
    :plugins => "paste,preview,insertdatetime,media",
    :theme_advanced_buttons1 => "formatselect,fontselect,fontsizeselect,|,forecolor,backcolor,|,mymenubutton,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,bullist,numlist",
    :theme_advanced_buttons2 =>",outdent,indent,|,undo,redo,|,cut,copy,paste,pastetext,pasteword,|,anchor,image,media,link,unlink,blockquote,|,cleanup,insertdate,inserttime,preview,code,|,help,",
    :theme_advanced_buttons3 => "",
    :theme_advanced_toolbar_location => "top",
    :theme_advanced_toolbar_align => "left",
    :theme_advanced_resizing => true,
    :theme_advanced_resize_horizontal => false,
  },
    :only => [:new,:edit]
  layout  "admin"
  caches_page :show
  def index
    @web_configs = WebConfig.all

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @web_configs }
    end
  end

  # GET /web_configs/1
  # GET /web_configs/1.xml
 
  def show  
   # @web_config=(/^\d+$/=~params[:id]) ? WebConfig.find(params[:id]) :( @tar=params[:id];WebConfig.find_by_name(params[:id]))
    #@web_config = WebConfig.find_by_name(@tar)
    @tag=params[:id]
    @web_config=WebConfig.find_by_name(params[:id])
    @title=@web_config.description
    respond_to do |format|
      format.html {render :layout => 'display'}
      format.xml  { render :xml => @web_config }
    end
  end

  # GET /web_configs/new
  # GET /web_configs/new.xml
  def new
    @web_config = WebConfig.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @web_config }
    end
  end

  # GET /web_configs/1/edit
  def edit
    @web_config = WebConfig.find(params[:id])
  end

  # POST /web_configs
  # POST /web_configs.xml  
  def create
    @web_config = WebConfig.new(params[:web_config])

    respond_to do |format|
      if @web_config.save
        flash[:notice] = 'WebConfig was successfully created.'
        format.html { redirect_to(company_path(@web_config.name)) }
        format.xml  { render :xml => @web_config, :status => :created, :location => @web_config }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @web_config.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /web_configs/1
  # PUT /web_configs/1.xml
  def update
    @web_config = WebConfig.find(params[:id])

    respond_to do |format|
      if @web_config.update_attributes(params[:web_config])
        flash[:notice] = 'WebConfig was successfully updated.'
        format.html { redirect_to(company_path(@web_config.name)) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @web_config.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /web_configs/1
  # DELETE /web_configs/1.xml
  def destroy
    @web_config = WebConfig.find(params[:id])
    @web_config.destroy

    respond_to do |format|
      format.html { redirect_to(web_configs_url) }
      format.xml  { head :ok }
    end
  end
end
